<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        function checkAll() {
            //getElementsByTagName：按照指定标签名进行查找并返回集合
            //这个集合的操作跟数组一样
            //集合中都是dom对象
            //集合中元素属性和html中从上到下的顺序
            var inputs = document.getElementsByTagName("input");
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].checked = true;
            }
        }
    </script>
</head>
<body>
    兴趣爱好
    <input type="checkbox" name="hobby" value="C++"/>C++
    <input type="checkbox" name="hobby" value="Java"/>Java
    <input type="checkbox" name="hobby" value="Python"/>Python
    <br/>
    <button onclick="checkAll()">全选</button>
</body>
</html>